package cn.kgcnews.utils;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


public class StringUtils {
	
	public static boolean checkImg(String fileName){
		String ext=getExt(fileName);
		List<String> exts=Arrays.asList(".gif", ".png", ".jpg");
		if(exts.contains(ext)){
			return true;
		}
		return false;
	}
	
	public static String getExt(String fileName){
		if(fileName!=null && !"".equals(fileName)){
			int index=fileName.lastIndexOf(".");
			return fileName.substring(index);
		}
		return null;
	}
	
	public static String getNewName(String fileName){
		String ext=getExt(fileName);
		SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
		return sdf.format(new Date())+ext;
	}
	
	public static void main(String[] args) {
		//System.out.println(getNewName("5.jpg"));
		System.out.println(checkImg("5.doc"));
	}
	
	
	
}
